package org.massdeception.content.entities;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.users.User;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Slide implements Serializable
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
    
    @Persistent
    private User author;
    
    @Persistent
    private String title;
    
    @Persistent
    private String url;
    
    @Persistent
    private String altText;
    
    @Persistent
    private Date uploadDate;
    
    @Persistent
    private Long publishDate;
    
    @Persistent
    private Blob image;
    
    @Persistent
    private String extension;
    
    /*
    private static SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    
    public String getFormattedPubDate()
    {
        try
        {
            return(formatter.format(this.publishDate));
        }
        catch (Throwable t)
        {
            return("");
        }
    }
    */
    
    public String getExtension()
    {
        return extension;
    }

    public void setExtension(String extension)
    {
        this.extension = extension;
    }

    public Slide()
    { 
        
    }

    public byte[] getBytes()
    {
        return this.image.getBytes();
    }

    public void setBytes(byte[] bytes)
    {
        this.image = new Blob(bytes);
    }

    public User getAuthor()
    {
        return author;
    }
    
    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public void setAuthor(User author)
    {
        this.author = author;
    }

    public String getTitle()
    {
        return title;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    public String getAltText()
    {
        return altText;
    }

    public void setAltText(String altText)
    {
        this.altText = altText;
    }

    public Date getUploadDate()
    {
        return uploadDate;
    }

    public void setUploadDate(Date uploadDate)
    {
        this.uploadDate = uploadDate;
    }

    public Long getPublishDate()
    {
        return publishDate;
    }

    public void setPublishDate(Long publishDate)
    {
        this.publishDate = publishDate;
    }
}
